package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TZhgdDeviceToolsRfidInfo;
import com.ruoyi.system.service.ITZhgdDeviceToolsRfidInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工器具tfidController
 * 
 * @author wuyafeng
 * @date 2025-01-16
 */
@Controller
@RequestMapping("/system/rfid")
public class TZhgdDeviceToolsRfidInfoController extends BaseController
{
    private String prefix = "system/rfid";

    @Autowired
    private ITZhgdDeviceToolsRfidInfoService tZhgdDeviceToolsRfidInfoService;

    @RequiresPermissions("system:rfid:view")
    @GetMapping()
    public String rfid()
    {
        return prefix + "/rfid";
    }

    /**
     * 查询工器具tfid列表
     */
    @RequiresPermissions("system:rfid:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TZhgdDeviceToolsRfidInfo tZhgdDeviceToolsRfidInfo)
    {
        startPage();
        List<TZhgdDeviceToolsRfidInfo> list = tZhgdDeviceToolsRfidInfoService.selectTZhgdDeviceToolsRfidInfoList(tZhgdDeviceToolsRfidInfo);
        return getDataTable(list);
    }

    /**
     * 导出工器具tfid列表
     */
    @RequiresPermissions("system:rfid:export")
    @Log(title = "工器具tfid", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TZhgdDeviceToolsRfidInfo tZhgdDeviceToolsRfidInfo)
    {
        List<TZhgdDeviceToolsRfidInfo> list = tZhgdDeviceToolsRfidInfoService.selectTZhgdDeviceToolsRfidInfoList(tZhgdDeviceToolsRfidInfo);
        ExcelUtil<TZhgdDeviceToolsRfidInfo> util = new ExcelUtil<TZhgdDeviceToolsRfidInfo>(TZhgdDeviceToolsRfidInfo.class);
        return util.exportExcel(list, "工器具tfid数据");
    }

    /**
     * 新增工器具tfid
     */
    @RequiresPermissions("system:rfid:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存工器具tfid
     */
    @RequiresPermissions("system:rfid:add")
    @Log(title = "工器具tfid", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TZhgdDeviceToolsRfidInfo tZhgdDeviceToolsRfidInfo)
    {
        return toAjax(tZhgdDeviceToolsRfidInfoService.insertTZhgdDeviceToolsRfidInfo(tZhgdDeviceToolsRfidInfo));
    }

    /**
     * 修改工器具tfid
     */
    @RequiresPermissions("system:rfid:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TZhgdDeviceToolsRfidInfo tZhgdDeviceToolsRfidInfo = tZhgdDeviceToolsRfidInfoService.selectTZhgdDeviceToolsRfidInfoById(id);
        mmap.put("tZhgdDeviceToolsRfidInfo", tZhgdDeviceToolsRfidInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存工器具tfid
     */
    @RequiresPermissions("system:rfid:edit")
    @Log(title = "工器具tfid", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TZhgdDeviceToolsRfidInfo tZhgdDeviceToolsRfidInfo)
    {
        return toAjax(tZhgdDeviceToolsRfidInfoService.updateTZhgdDeviceToolsRfidInfo(tZhgdDeviceToolsRfidInfo));
    }

    /**
     * 删除工器具tfid
     */
    @RequiresPermissions("system:rfid:remove")
    @Log(title = "工器具tfid", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tZhgdDeviceToolsRfidInfoService.deleteTZhgdDeviceToolsRfidInfoByIds(ids));
    }
}
